package com.grt192.spot.mechanism.WallHugger;

import com.grt192.controller.pid.PIDOutput;
import com.grt192.controller.pid.PIDSource;
import com.grt192.core.CommandArray;
import com.grt192.spot.mechanism.hauntedHouse.StatusLight;
import com.sun.spot.resources.transducers.ILightSensor;
import java.io.IOException;

/**
 *
 * @author ajc
 */
public class StatusLightPID implements PIDSource, PIDOutput{
    private final StatusLight light;
    private final ILightSensor sensor;

    public StatusLightPID(StatusLight light, ILightSensor sensor){
        this.light = light;
        this.sensor = sensor;
    }

    
    public void pidWrite(double result) {
        light.rawColor(new CommandArray(result, result, result));
    }

    public double pidGet() {
        try {
            return sensor.getAverageValue();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        return -999;
    }

}
